public class Test {
    public static void main(String[] args) {
        String str = "abbba";
        int ret = getLongestPalindrome(str);
        System.out.println(ret);
    }

    public static int getLongestPalindrome (String A) {
        // write code here
        int count = 0;
        int left = 0;
        int right = A.length() - 1;
        while(left <= right){
            while(left <= right && A.charAt(left) == A.charAt(right)){
                if(left == right){
                    count++;
                    left++;
                    right--;
                }else {
                    count += 2;
                    left++;
                    right--;
                }
            }
            if(left < right){
                left++;
                right--;
            }
        }
        return count;
    }
}
